package com.rhem.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;

public class HomePanel extends Composite {
	@UiField
	AbsolutePanel galeria;
	
	@UiField
	HTMLPanel panelItem;
	
	Timer timer;
	GaleriaAnimation animation;
	
	@UiField
	Image img1;
	
	@UiField
	Image img2;
	
	//@UiField
	//Image img3;
	
	
	@UiField
	Anchor acid;
	/*
	@UiField
	ListBox conversation;
	
	@UiField
	Button send;
	
	@UiField
	TextBox message;
	*/
	HomePanel singleton;

	private static HomePanelUiBinder uiBinder = GWT
			.create(HomePanelUiBinder.class);

	interface HomePanelUiBinder extends UiBinder<Widget, HomePanel> {
	}

	public HomePanel() {
		singleton = this;
		initWidget(uiBinder.createAndBindUi(this));
		img1.setUrl(GWT.getHostPageBaseURL()+"upload/img/sistemaventas.png");
		img2.setUrl(GWT.getHostPageBaseURL()+"upload/img/sistemamovil.png");
		//img3.setUrl(GWT.getHostPageBaseURL()+"upload/img/img1.png");
		
		animation = new GaleriaAnimation();
		animation.absolutePanel = galeria;
		animation.htmlPanel = panelItem;
		animation.onComplete();
		
		acid.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				//Window.open("http://acid3.acidtests.org/", "_blank", null);
				Window.open("http://noticias-industria.gaf.pe/2011/04/industria-textil-de-gamarra-apuesta-a-conquistar-mercado-brasileno/", "_blank", null);
				
			}
		});
		/*
		message.addKeyDownHandler(new KeyDownHandler() {
			
			@Override
			public void onKeyDown(KeyDownEvent event) {
				if(event.getNativeKeyCode() == KeyCodes.KEY_ENTER)					
					singleton.addMessage();				
			}
		});
		send.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				singleton.addMessage();
			}
		});
		*/
		/*timer = new Timer(){
			@Override
			public void run() {
				animation.run(1500);				
			}			
		};
		timer.schedule(2000);*/
	}
	
	/*private void addMessage(){
		if(!message.getText().trim().equals("")){
			conversation.addItem("Usuario - "+message.getValue().trim());
			int cont = conversation.getItemCount();				
			conversation.setSelectedIndex(cont-1);			
			message.setValue("");
			message.setFocus(true);
		}
	}*/

}
